﻿using System;

namespace EasyConveyor
{
	/// <summary>
	/// Provides data for the <see cref="Application.Error"/> event.
	/// </summary>
	public sealed class MiddlewareErrorEventArgs : EventArgs
	{
		internal MiddlewareErrorEventArgs(ActivatorBase activator, Type middlewareType, IMiddleware middleware, object context, Exception ex)
		{
			Activator = activator;
			MiddlewareType = middlewareType;
			Middleware = middleware;
			Context = context;
			Exception = ex;
		}
		
		/// <summary>
		/// Gets the instance of the activator that activated the request on which the error occurred.
		/// </summary>
		public ActivatorBase Activator { get; private set; }
		/// <summary>
		/// Gets the type of the middleware that caused the error.
		/// </summary>
		public Type MiddlewareType { get; private set; }
		/// <summary>
		/// Gets the instance of the middleware that caused the error.
		/// </summary>
		public IMiddleware Middleware { get; private set; }
		/// <summary>
		/// Gets the context associated with request on which the error occurred.
		/// </summary>
		public object Context { get; private set; }
		/// <summary>
		/// Gets the <see cref="Exception"/> that was thrown.
		/// </summary>
		public Exception Exception { get; private set; }
	}
}
